//
//  UILabel+YBAttributeTextTapAction.h
//
//  Created by LYB on 16/7/1.
//  Copyright © 2016年 LYB. All rights reserved.
//
/*
 
 NSString *intStr = @"登录或注册即表示同意遵守 《搜缘使用协议》";
 NSDictionary *intDic=@{NSFontAttributeName:FONTSIZE(14),NSForegroundColorAttributeName:KLightGrayColor};
 NSMutableAttributedString *intAbuted = [[NSMutableAttributedString alloc]initWithString:intStr attributes:intDic];
 [intAbuted addAttribute:NSFontAttributeName value:FONTSIZE(14) range:NSMakeRange(intStr.length-8, 8)];//变大
 [intAbuted addAttribute:NSForegroundColorAttributeName value:KRedColor range:NSMakeRange(intStr.length-8, 8)];
 
 // 创建一个文字附件对象
 //    NSTextAttachment *textAttachment = [[NSTextAttachment alloc] init];
 //    textAttachment.image = [UIImage imageNamed:@"image.png"];  //设置图片源
 //    textAttachment.bounds = CGRectMake(0, -6, 30, 30);  //设置图片位置和大小
 //    // 将文字附件转换成属性字符串
 //    NSAttributedString *attachmentAttrStr = [NSAttributedString attributedStringWithAttachment:textAttachment];
 // 将转换成属性字符串插入到目标字符串
 //    [attrStr insertAttributedString:attachmentAttrStr atIndex:labelString.length];
 
 CGSize SIZE = [self sizeWithString:intStr font:FONTSIZE(14) maxWidth:kScreenWidth];
 int labelX = (kScreenWidth - SIZE.width)/2;
 
 UILabel *ybLabel1 = [[UILabel alloc] initWithFrame:CGRectMake(labelX,  kRealValue(587), SIZE.width, 21)];
 //    ybLabel1.textAlignment = NSTextAlignmentCenter;
 ybLabel1.attributedText = intAbuted;
 [self.view addSubview:ybLabel1];
 [ybLabel1 yb_addAttributeTapActionWithStrings:@[@"《搜缘使用协议》"] delegate:self];
 
*/
#import <UIKit/UIKit.h>

@protocol YBAttributeTapActionDelegate <NSObject>
@optional
/**
 *  YBAttributeTapActionDelegate
 *
 *  @param string  点击的字符串
 *  @param range   点击的字符串range
 *  @param index 点击的字符在数组中的index
 */
- (void)yb_attributeTapReturnString:(NSString *)string
                              range:(NSRange)range
                              index:(NSInteger)index;
@end

@interface YBAttributeModel : NSObject

@property (nonatomic, copy) NSString *str;

@property (nonatomic, assign) NSRange range;

@end





@interface UILabel (YBAttributeTextTapAction)

/**
 *  给文本添加点击事件Block回调
 *
 *  @param strings  需要添加的字符串数组
 *  @param tapClick 点击事件回调
 */
- (void)yb_addAttributeTapActionWithStrings:(NSArray <NSString *> *)strings
                                 tapClicked:(void (^) (NSString *string , NSRange range , NSInteger index))tapClick;

/**
 *  给文本添加点击事件delegate回调
 *
 *  @param strings  需要添加的字符串数组
 *  @param delegate delegate
 */
- (void)yb_addAttributeTapActionWithStrings:(NSArray <NSString *> *)strings
                                   delegate:(id <YBAttributeTapActionDelegate> )delegate;

@end

